package com.cm.caseManagement.controller;
import com.cm.caseManagement.annotation.Log;
import com.cm.caseManagement.core.controller.BaseController;
import com.cm.caseManagement.core.domain.AjaxResult;
import com.cm.caseManagement.core.page.TableDataInfo;
import com.cm.caseManagement.pojo.entity.CmCaseApplyRecord;
import com.cm.caseManagement.pojo.enums.BusinessType;
import com.cm.caseManagement.service.ICmCaseApplyRecordService;
import com.cm.caseManagement.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 案件申报记录中间Controller
 *
 * @author ruoyi
 * @date 2025-10-05
 */
@RestController
@RequestMapping("/caseManagement/caseApplyRecord")
public class CmCaseApplyRecordController extends BaseController
{
    @Autowired
    private ICmCaseApplyRecordService cmCaseApplyRecordService;

    /**
     * 查询案件申报记录中间列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmCaseApplyRecord cmCaseApplyRecord)
    {
        startPage();
        List<CmCaseApplyRecord> list = cmCaseApplyRecordService.selectCmCaseApplyRecordList(cmCaseApplyRecord);
        return getDataTable(list);
    }

    /**
     * 导出案件申报记录中间列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:export')")
    @Log(title = "案件申报记录中间", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmCaseApplyRecord cmCaseApplyRecord)
    {
        List<CmCaseApplyRecord> list = cmCaseApplyRecordService.selectCmCaseApplyRecordList(cmCaseApplyRecord);
        ExcelUtil<CmCaseApplyRecord> util = new ExcelUtil<CmCaseApplyRecord>(CmCaseApplyRecord.class);
        util.exportExcel(response, list, "案件申报记录中间数据");
    }

    /**
     * 获取案件申报记录中间详细信息
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cmCaseApplyRecordService.selectCmCaseApplyRecordById(id));
    }

    /**
     * 新增案件申报记录中间
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:add')")
    @Log(title = "案件申报记录中间", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmCaseApplyRecord cmCaseApplyRecord)
    {
        return toAjax(cmCaseApplyRecordService.insertCmCaseApplyRecord(cmCaseApplyRecord));
    }

    /**
     * 修改案件申报记录中间
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:edit')")
    @Log(title = "案件申报记录中间", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmCaseApplyRecord cmCaseApplyRecord)
    {
        return toAjax(cmCaseApplyRecordService.updateCmCaseApplyRecord(cmCaseApplyRecord));
    }

    /**
     * 删除案件申报记录中间
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:record:remove')")
    @Log(title = "案件申报记录中间", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cmCaseApplyRecordService.deleteCmCaseApplyRecordByIds(ids));
    }
}
